package com.irain.pp.tool;


import com.irain.pp.tool.exception.BizException;

import java.util.Objects;

/**
 * @author WangYanPeng
 * @date 2017/10/27 19:49
 */
public class BizAssert {

    public static void isNull(Object object,String errorMsg){
        if (object != null){
            throw new BizException(errorMsg);
        }
    }

    public static void isBlank(String text,String errorMsg){
        if (text == null || "".equals(text)){
            throw new BizException(errorMsg);
        }
    }

    public static void isEqual(Object o1,Object o2,String errorMsg){
        if (!Objects.equals(o1,o2)){
            throw new BizException(errorMsg);
        }
    }

    public static void isTrue(boolean result,String errorMsg){
        if (!result){
            throw new BizException(errorMsg);
        }
    }

    public static void notNull(Object object,String errorMsg){
        if (object == null){
            throw new BizException(errorMsg);
        }
    }

    public static void notBlank(String text,String errorMsg){
        if (text != null && !"".equals(text)){
            throw new BizException(errorMsg);
        }
    }

    public static void notEqual(Object o1,Object o2,String errorMsg){
        if (Objects.equals(o1,o2)){
            throw new BizException(errorMsg);
        }
    }

    public static void notTrue(boolean result,String errorMsg){
        if (result){
            throw new BizException(errorMsg);
        }
    }
}
